from itertools import groupby
lst = [30, 20, 99, 50, 60, 65, 80, 90, 85, 88]


def func(num):
    if num < 60:
        return '不及格'
    elif num <= 70:
        return '及格'
    else:
        return '良好'


ite = groupby(sorted(lst), key=func)

for k, item in ite:
    print(f'key 为：{k}； 对应分组的内容为：{list(item)}')